import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_shop/routers/i_router.dart';
import 'package:flutter_shop/routers/not_found_page.dart';

class Routes {
  static String home = '/home';
  static String webViewPage = '/webView';
  static final List<IRouterProvider> _listRouter = [];
  static final FluroRouter router = FluroRouter();

  static void initRoutes() {
    router.notFoundHandler = Handler(handlerFunc: (
      BuildContext? context,
      Map<String, List<String>> parameters,
    ) {
      debugPrint("未找到目标页面");
      return const NotFoundPage();
    });

    _listRouter.clear();


    // 初始化
    void initRouter(IRouterProvider routerProvider) {
      routerProvider.initRouter(router);
    }
    _listRouter.forEach(initRouter);
  }
}
